import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;

public class Connections {

    Connections() { }

    public ServerSocket OpenServerSocket(int portNum) throws IOException {
       //Create socket to listen at a specified port
       return (new ServerSocket(portNum));
    }

    public Socket ConnectToClientSocket(ServerSocket argServerSocket) throws IOException {
       //Connects to the client socket
       return(argServerSocket.accept());   
    }

    public void DisconnectFromClientSocket(Socket argClientSocket) throws IOException {
        argClientSocket.close();
    }

    public DatagramSocket OpenDatagramSocket(int port,InetAddress addr) throws SocketException  {
        return (new DatagramSocket(port,addr));
    }

    public DatagramPacket GetDatagramPacket(byte[] buf, int len) {
        return (new DatagramPacket(buf,len));
    }
}
